package com.linln.modules.member.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.modules.system.domain.User;

import lombok.Data;

/**
 * @author hct
 * @date 2019/09/12
 */
@Data
@Entity
@Table(name="memberinfo")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class MemberInfo implements Serializable {
    // 主键ID
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    // 昵称
    private String nickname;
    // 头像
    private String headimg;
    // openid
    private String openid;
    // 注册时间
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date registerDate;
    // 余额
    private Double money;
    //总收入一直累加
    private Double allmoney;    
    // 积分
    private Integer score;
    // 发帖数
    private Integer messagenum;
    // 所属城市
    private String city;
    
    private String area;
    private String areaname;

    // 电话
    private String mobile;
    
    //设置密码
    @JsonIgnore
    private String password;
    @JsonIgnore
    private String salt;
    // 地址
    private String address;
    
    private String sex;
    private String birthday;
    private String userarea;
    private String occupation;
    private String hobby;
    private String descrition;
    private String education;
    private String selfdesc;
    //代表是否是代理商 0不是1是
    private Integer isagent;
    // 创建时间
    @CreatedDate
    private Date createDate;
    // 更新时间
    @LastModifiedDate
    private Date updateDate;
    // 发布人
    @CreatedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="create_by")
    @JsonIgnore
    private User createBy;
    // 修改人
    @LastModifiedBy
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="update_by")
    @JsonIgnore
    private User updateBy;
    // 状态
    private Byte status = StatusEnum.OK.getCode();
    
    @Transient
    private List<MemberAgent> agentList;

    private String sessionKey;

    private String signature;

    private String rawData;
    
}